package com.tebiecloud.common.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 请求拦截器
 * @Author: tebie
 * @Date: 2019-08-04 11:11
 */
public class XssFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        try {
            HttpServletRequest req = (HttpServletRequest) request;
            XssHttpServletRequestWrapper xssRequestWrapper = new XssHttpServletRequestWrapper(req);
            chain.doFilter(xssRequestWrapper, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void destroy() {

    }

}
